package model

import (
	"choujiang/common/db"
	"fmt"
)

type Advertisement struct {
	Id       int64  `xorm:"INT(11) not null pk autoincr"`
	Name     string `xorm:"VARCHAR(100) not null"`
	Desc     string `xorm:"VARCHAR(100) not null"`
	Cover    string `xorm:"VARCHAR(100) not null"`
	Type     int64  `xorm:"INT(4) not null default 1 comment('1小程序跳转/2文章url')"`
	Position int64  `xorm:"INT(4) not null default 1 comment('1头部')"`
	Url      string `xorm:"VARCHAR(100) not null"`
	Content  string `xorm:"VARCHAR(255) not null"`
	Order    int64  `xorm:"INT(11) not null default 1"`
	ClickNum int64  `xorm:"INT(11) not null default 0"`
	Status   int64  `xorm:"INT(11) not null default 1"`

	CreatedAt int64 `xorm:"not null default 0 INT(11) created"`
	UpdatedAt int64 `xorm:"not null default 0 INT(11) updated"`
}

func GetAdvertList(position int64) []Advertisement {
	advert := make([]Advertisement, 0)
	err := db.MysqlEngine.Where("position=?", position).Find(&advert)
	if err != nil {
		fmt.Printf("GetAdvertList err %+v\n", err)
	}
	return advert
}
